package pressuretest;

import java.time.Instant;

import api.PurseApi;

/**
 * 查询通宝
 * @author 高文
 *
 */
public class TongBao
{
	/**
	 * 查询通宝
	 * @param sid 服务器id
	 * @param uid 用户id
	 * @return 成功或错误信息
	 */
	public static String CheckBalance(int sid, int uid)
	{
		String testResult="成功";
		try
		{
			PurseApi.msQueue(sid, uid, Instant.now().getEpochSecond());
			int i=300;
			while(i>0)
			{
				String purseResult=PurseApi.msQueueResult(sid);
				if (purseResult == null || purseResult.isEmpty())
				{
					Thread.sleep(1000);
					i--;
				}
				else 
				{
					System.out.println(purseResult);
					break;
				}
			}
			
		}
		catch (Exception e)
		{
			return e.getMessage();// TODO: handle exception
		}
		return testResult;
	}
	
	public static void main(String[] args)
	{
		String result=CheckBalance(88881, 888);
		System.out.println(result);
	}
}
